/**
 * @constructor
 * @param {String} mapname
 */
Game = function(mapname) {
  var that = this;
  var entities_ = [];
  var gravity_ = new Vec2(0,.2);
  var map_ = new Image();
  map_.src = mapname;


  /**
   * @return {Image}
   */
  that.GetMap = function() {
    return map_;
  }

  /**
   * @return {Number}
   */
  that.GetGravity = function() {
    return gravity_.Copy();
  }

  that.AddEntity = function(e) {
    entities_.push(e);
  }

  that.Update = function(tick) {
    for (var i = 0, ent; ent = entities_[i]; ++i) {
      ent.Update(tick);
    }
  }

  /**
   *
   * @param {CanvasContext} ctx
   */
  that.Draw = function(ctx) {
    ctx.clearRect(0,0,ctx.canvas.width, ctx.canvas.height);
    ctx.drawImage(map_, 0, 0);
    for (var i = 0, ent; ent = entities_[i]; ++i) {
      ent.CheckCollisions(ctx);
      ent.Draw(ctx);
    }
  }

 }
